package com.shop.mall.utils;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


/**
 * 配置获取
 */
public class PropertyUtil {
	
	public static Properties loadProps(InputStream in) {
		System.out.println("开始加载properties文件内容.......");
		Properties props = new Properties();
		try {
			// 第一种，通过类加载器进行获取properties文件流
			// 第二种，通过类进行获取properties文件流
			// in = PropertyUtil.class.getResourceAsStream("/jdbc.properties");
			props.load(in);
		} catch (FileNotFoundException e) {
			System.out.println("文件未找到");
		} catch (IOException e) {
			System.out.println("出现IOException");
		} finally {
			try {
				if (null != in) {
					in.close();
				}
			} catch (IOException e) {
				System.out.println("文件流关闭出现异常");
			}
		}
		System.out.println("加载properties文件内容完成...........");
		System.out.println("properties文件内容：" + props);
		return props;
	}
}